//
//  TwERPLabourItem.m
//  TwERP
//
//  Created by Xiangyang Li on 12-7-2.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "TwERPLabourItem.h"
#import "TwERPJsonAgent.h"

@implementation TwERPLabourItem

@synthesize description =_description;
@synthesize price = _price;
@synthesize quantity =_quantity;

- (id)initWithNewId {
    self = [super initWithNewId];
    if (self) {
        // Initialize self.
        self.quantity =1;
        self.description = @"";
    }
    return self;
}

+ (NSArray *) itemDefsWithKeyword:(NSString *)keyword
{
    NSArray *partDictList=[TwERPJsonAgent getLabourListByKeyword:keyword];
    NSMutableArray *partList = [[NSMutableArray alloc] init];
    
    for (NSDictionary *pDict in partDictList)
    {
        TwERPLabourItem * part =[[TwERPLabourItem alloc] init];
        [part setValuesForKeysWithDictionary:pDict];
        [partList addObject:part];
    }
    return partList;

}
+ (NSArray *) itemDefsWithCategory:(int)categoryId
{
    NSArray *partDictList=[TwERPJsonAgent getLabourListByCategoryId:categoryId];
    NSMutableArray *partList = [[NSMutableArray alloc] init];
    
    for (NSDictionary *pDict in partDictList)
    {
        TwERPLabourItem * part =[[TwERPLabourItem alloc] init];
        [part setValuesForKeysWithDictionary:pDict];
        [partList addObject:part];
    }
    return partList;
}
@end
